import React from 'react'
import LinkA from '@/components/publics/LinkA.jsx'
import { Button } from 'antd'
/**
 * 返回列表的构造数据项
 * @param {this} self
 */
export default (self) => {
  return [
    {
      title: '商品名称',
      key: 'name',
      dataIndex: 'name',
    },
    {
      title: '商品描述',
      key: 'detail',
      dataIndex: 'detail',
      render: (text) => <div dangerouslySetInnerHTML={{ __html: text }}></div>,
    },
    {
      title: '价格',
      key: 'price',
      dataIndex: 'price',
      render: (text) => `￥${text}`,
    },
    {
      title: '状态',
      key: 'status',
      dataIndex: 'status',
      render: (text, record) =>
        text === 1 ? (
          <Button type="primary" onClick={() => self.updateStatus(record, 2)}>
            下架
          </Button>
        ) : (
          <Button type="primary" onClick={() => self.updateStatus(record, 1)}>
            上架
          </Button>
        ),
    },
    {
      width: 300,
      title: '操作',
      key: 'categoryId',
      dataIndex: 'categoryId',
      render: (text, record, index) => (
        <span>
          <LinkA
            title="详情"
            onClickLink={() => self.detailProduct(record)}
          ></LinkA>
          <LinkA
            title="修改"
            onClickLink={() => self.editProduct(record)}
          ></LinkA>
        </span>
      ),
    },
  ]
}
